/*
 * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package io.iec.edp.caf.commons.dataaccess;

/**
 * 数据库类型
 * @author wangyandong
 * @date 2019/10/23 16:53
 *
 */
//todo 被com.inspur.edp.cef.repository.adaptor.KeyWordsManager依赖
public enum DbType {


    SQLServer(0),
    Oracle(1),
    PgSQL(2),
    MySQL(3),
    DM(4),
    HighGo(5),
    Gbase(6),
    Kingbase(7),
    Oscar(8),
    DB2(9),
    OpenGauss(10),
    OceanBase(11),
    GBase8s(12),
    GBase8c(13),
    GaussDB(14),
    Unknown(-1);
    private int value;
    private DbType(int value) {
        this.value=value;
    }

    private DbType() {
    }

    public int getValue(){
        return value;
    }

    public static  DbType fromValue(int value){
        for(DbType dbType:DbType.values()){
            if(dbType.getValue()==value){
                return dbType;
            }
        }
        throw new IllegalArgumentException("Invalid DbType Value: "+value);
    }

    /**
     * 判断是否是SQLServer
     * 用于隐式转换的判断
     * @return
     */
    public Boolean isImplicitConvert() {
        return this == SQLServer;
    }
}
